import { IsString, IsNumber, IsOptional, Min, Max, IsNotEmpty } from 'class-validator';

export class CreateGoodDto {
  @IsString()
  @IsNotEmpty({ message: '商品名称不能为空' })
  name: string;

  @IsNumber()
  @Min(0, { message: '价格不能小于0' })
  @Max(1000000, { message: '价格不能超过1000000' })
  price: number;

  @IsString()
  @IsOptional()
  description?: string;
}

export class GoodResponseDto {
  id: number;
  name: string;
  price: number;
  description?: string;
  createdAt: Date;
}

export class UpdateGoodDto {
  @IsString()
  @IsOptional()
  name?: string;

  @IsNumber()
  @Min(0)
  @Max(1000000)
  @IsOptional()
  price?: number;

  @IsString()
  @IsOptional()
  description?: string;
}